import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

export type PageResult = {
  success: boolean;
  data: {
    /** 列表数据 */
    list: Array<any>;
    /** 总数 */
    total?: number;
  };
  errMsg: "";
};

export type DataResult = {
  success: boolean;
  errMsg: "";
};

export const queryElevatorList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryElevatorList"), {
    data
  });
};

export const queryElevatorListByUser = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryElevatorListByUser"),
    {
      data
    }
  );
};

export const addOrUpdateElevator = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("addOrUpdateElevator"), {
    data
  });
};

export const deleteElevator = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteElevator"), {
    data
  });
};

export const querySysUserListByBm = () => {
  return http.request<PageResult>("get", baseUrlApi("querySysUserListByBm"));
};

////////////////////user door//////////////

export const queryCommunityUserDoorByUser = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryCommunityUserDoorByUser"),
    {
      data
    }
  );
};

export const updateUserDoor = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("updateUserDoor"), {
    data
  });
};

export const deleteUserDoor = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteUserDoor"), {
    data
  });
};

//////////
export const queryAdminGrantList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryAdminGrantList"), {
    data
  });
};

export const updateAdminGrantStatus = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("updateAdminGrantStatus"),
    {
      data
    }
  );
};

export const deleteAdminGrant = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteAdminGrant"), {
    data
  });
};

////////

export const queryPointsList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryPointsList"), {
    data
  });
};

export const addOrUpdatePoints = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("addOrUpdatePoints"), {
    data
  });
};

export const deletePoints = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deletePoints"), {
    data
  });
};
